import request from '@/utils/request';
import url from 'postcss-url';

// 竞赛平台（Competition platform  === CP ）接口

//教师端------任务管理---start
// 获取任务列表
export function getTaskListCP(courseId) {
    return request({
        url: `/tes/course/${courseId}/chapter/list/owner`,
        method: 'get',
    })
}
//新增任务
export function addTaskCP(courseId, data) {
    return request({
        url: `/tes/course/${courseId}/chapter`,
        method: 'post',
        data
    })
}
//查看某个任务名称和分数
export function getOnesInfoCP(courseId, taskId) {
    return request({
        url: `/tes/course/${courseId}/chapter/${taskId}/info`,
        method: 'get',
    })
}
//修改任务
export function modifyTaskCP(courseId, taskId, data) {
    return request({
        url: `/tes/course/${courseId}/chapter/${taskId}`,
        method: 'put',
        data
    })
}
//获取任务说明和参考答案的内容
export function getTaskAndAnswerInfoCP(courseId, taskId) {
    return request({
        url: `/tes/course/${courseId}/chapter/${taskId}/make/resource?types=8,14,18`,
        method: 'get',
    })
}
//修改任务说明或者参考答案的内容
export function modifyTaskAndAnswerInfoCP(url, data) {
    return request({
        url: url,
        method: 'post',
        data
    })
}
//批量删除任务 ,data参数及说明 [ 4744 ] 
export function batchDeleteTaskCP(courseId, data) {
    return request({
        url: `/tes/course/${courseId}/chapter/batch-delete`,
        method: 'post',
        data
    })
}
//获取判定列表
export function getJudgeListCP(taskId) {
    return request({
        url: `/tes/experiment/judge/info?type=1&contextId=${taskId}`,
        method: 'get',
    })
}
//添加/修改判定 参数体data里有id属性代表修改；如果不传这个字段，代表添加
export function addOrModifyJudgeCP(data) {
    return request({
        url: `/tes/experiment/judge/save`,
        method: 'post',
        data
    })
}
//删除判定 data=[ 判定id ]
export function deleJudgeCP(data) {
    return request({
        url: `/tes/experiment/judge/delete`,
        method: 'post',
        data
    })
}
//获取课程名称、章节名称及任务分数
export function getTaskAndScoreInfoCP(courseId, taskId) {
    return request({
        url: `/tes/course/${courseId}/chapter/${taskId}`,
        method: 'get',
    })
}
//教师端------任务管理---end



// 教师学生通用(Teacher Student === TS)------竞赛接口---start
// 获取团队信息
export function getTeamInfoTSCP(courseId) {
    return request({
        url: `/tes/unauthorized/apply/group/info/${courseId}`,
        method: 'get',
    })
}
//获取任务列表
export function getTaskListTSCP(courseId) {
    return request({
        url: `/tes/course/${courseId}/chapter/list`,
        method: 'get',
    })
}
//竞赛信息、竞赛实况
export function getLiveTSCP(courseId) {
    return request({
        url: `/tes/match-report/schedule?courseId=${courseId}`,
        method: 'get',
    })
}
//竞赛实时推送websocket  之前逻辑：用户登录，就会启动websocket，现在保持不变。
export function getLiveWebsocketTSCP() {
    return request({
        url: `/tes/ws/global`,
        method: 'get',
    })
}
//获取竞赛题目
export function getTopicTSCP(courseId, taskId) {
    return request({
        url: `/tes/course/${courseId}/chapter/${taskId}/target`,
        method: 'get',
    })
}
//获取报告是markdown版本还是word版本
export function getReportTypeTSCP(courseId) {
    return request({
        url: `/tes/match/info/${courseId}`,
        method: 'get',
    })
}
//获取报告
export function getReportTSCP(courseId, taskId) {
    return request({
        url: `/tes/match-report?courseId=${courseId}&chapterId=${taskId}`,
        method: 'get',
    })
}
//保存或提交markdown报告
export function postMarkdownTSCP(data) {
    return request({
        url: `/tes/match-report`,
        method: 'post',
        data
    })
}
//上传word版本报告
export function postWordTSCP(data) {
    return request({
        url: `/tes/match-report/upload`,
        method: 'post',
        data
    })
}
//获取是否展示同步已提交报告按钮
export function getSynchronousTSCP(courseId, taskId) {
    return request({
        url: ``,
        method: 'get',
    })
}
//同步已提交报告
export function SynchronousReportTSCP(data) {
    return request({
        url: `/tes/match-report/sync-markdown`,
        method: 'post',
        data
    })
}
//倒计时获取时间
export function getCountdownTSCP(courseId, taskId) {
    return request({
        url: `/tes/match/timeLeft/${courseId}`,
        method: 'get',
    })
}
// 教师学生通用(Teacher Student === TS)------竞赛接口---end



//教师端----评委管理---start
// 添加评委
export function addTheJudges(courseId, data) {
    return request({
        url: `/tes/comment/${courseId}/add`,
        method: 'post',
        data
    })
}
// 批量删除
export function deleteTheJudges(courseId, data) {
    return request({
        url: `/tes/comment/${courseId}/delete`,
        method: 'post',
        data
    })
}
// 批量导入
export function importExcelTheJudges(courseId, data) {
    return request({
        url: `/tes/comment/${courseId}/importExcel`,
        method: 'post',
        data
    })
}
// 列表
export function theJudgesListByPage(courseId, data) {
    return request({
        url: `/tes/comment/${courseId}/list`,
        method: 'post',
        data
    })
}
// 任务列表
export function theTaskList(courseId) {
    return request({
        url: `/tes/comment/${courseId}/task/list`,
        method: 'get',
    })
}
//初始化密码/tes/user/21321/init-password
export function initPassWord(Id) {
    return request({
        url: `/tes/user/${Id}/init-password`,
        method: 'put',
    })
}
// 审批状态/tes/match/tea-set/comment/222222
export function examinationApprovalStatus(courseId) {
    return request({
        url: `/tes/match/tea-set/comment/${courseId}`,
        method: 'get',
    })
}
//教师端----评委管理---end



//教师端----竞赛审批---start

//获取批阅章节列表
export function getApprovalList(courseId) {
    return request({
        url: `/tes/match-report/check/task?courseId=${courseId}`,
        method: 'get'
    })
}
//获取批阅人员列表 
export function getApprovalPlayerList(courseId, taskId, status) {
    return request({
        url: `/tes/match-report/check/task/player?courseId=${courseId}&taskId=${taskId}&status=${status}`,
        method: 'get'
    })
}
//获取课程名称、章节名称及任务分数
export function getCourseChatperTask(courseId, taskId) {
    return request({
        url: `/tes/course/${courseId}/chapter/${taskId}`,
        method: 'get'
    })
}
//获取某个选手报告
export function getOnesPlayerReport(courseId, taskId, matchNumber) {
    return request({
        url: `/tes/match-report/check?courseId=${courseId}&taskId=${taskId}&matchNumber=${matchNumber}`,
        method: 'get'
    })
}
//获取选手的判定结果
export function getPlayerJudgeResultApi(params) {
    return request({
        url: `/tes/match-report/judge-result`,
        method: 'get',
        params
    })
}
//提交批阅
export function submitResultsForApproval(data) {
    return request({
        url: `/tes/match-report/check`,
        method: 'post',
        data
    })
}
//教师端----竞赛审批---end



//教师端----竞赛排名---start
//团队赛排名
export function TeamRanking(courseId,data) {
    return request({
        url: `/tes/ranking/${courseId}/list-group`,
        method: 'post',
        data
    })
}
// 个人赛排名
export function PersonalRanking(courseId,data) {
    return request({
        url: `/tes/ranking/${courseId}/list-person`,
        method: 'post',
        data
    })
}
// 竞赛排名-数据下载
export function RankingDataDown(courseId,data) {
    return request({
        url: `/tes/ranking/${courseId}/data-download`,
        method: 'post',
        data
    })
}
//竞赛排名-分数调整
export function RankingScoreSet(courseId,data) {
    return request({
        url: `/tes/ranking/${courseId}/setting-score`,
        method: 'post',
        data
    })
}
//教师端----竞赛排名---end



//竞赛实况---start
export function RealTimeRanking(courseId) {
    return request({
        url: `/tes/match-report/schedule-statistics?courseId=${courseId}`,
        method: 'get'
    })
}
//竞赛实况---end

// 是否展示选手参考答案
export function showUserAnswerApi(courseId) {
    return request({
        url: `/tes/match/info/${courseId}/config`,
        method: 'get'
    })
}

// 获取选手参考答案内容
export function getUserAnswerApi(courseId, taskId) {
    return request({
        url: `/tes/course/${courseId}/chapter/${taskId}/answer`,
        method: 'get'
    })
}